<template>
  <div class="fish-card">
    <img class="bg" :src="bgUrl" />
    <div class="fish-box">
      <p class="title">{{ title }}</p>
      <div class="line"></div>
      <p class="container">{{ container }}</p>
    </div>
  </div>
</template>

<script setup lang="ts" name="FishCard">
const Prop = defineProps({
  title: {
    type: String,
    default: 'asdf',
  },
  container: {
    type: String,
    default: 'asdf',
  },
  bgUrl: {
    type: String,
    default: '',
  },
});
</script>

<style lang="scss" scoped>
.fish-card {
  width: 100%;
  position: relative;
  color: #fff;
  text-transform: uppercase;
  backface-visibility: hidden;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
  .fish-box {
    position: absolute;
    box-sizing: border-box;
    padding: 30px;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    .title {
      margin: 8px 0;
      font-weight: bold;
      font-size: 1.35em;
      line-height: 1.5;
      -webkit-line-clamp: 2;
    }
    .line {
      background: #fff;
      height: 3px;
      width: 0px;
      transition: all 0.3s;
    }
    .container {
      position: absolute;
      left: 300px;
      margin: 0;
      padding: 8px 0 0;
      letter-spacing: 1px;
      font-size: 1.1em;
      line-height: 1.5;
      -webkit-line-clamp: 4;
      transition: all 0.3s;
    }
  }
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
  }
}
.fish-card:hover {
  .bg {
    transform: scale(1.2);
  }
  .line {
    width: 100%;
  }
  .container {
    left: 30px !important;
  }
}
.fish-card::before {
  display: block;
  content: '';
  width: 100%;
  padding-top: 100%; // 最重要的，利用伪元素的padding-top(也可以使用padding-bottom)去撑开box盒子的高度，100%是定撑开的高度所占的比
}

@media (max-width: 580px) {
  .fish-card {
    .fish-box {
      padding: 5px;
    }
  }
}
</style>
